<?php

/**
 * Conducteur filter form base class.
 *
 * @package    SdCommerce
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseConducteurFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'code'           => new sfWidgetFormFilterInput(),
      'nom'            => new sfWidgetFormFilterInput(),
      'prenom'         => new sfWidgetFormFilterInput(),
      'telephone'      => new sfWidgetFormFilterInput(),
      'commission'     => new sfWidgetFormFilterInput(),
      'bloque'         => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'principal'      => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'civilite'       => new sfWidgetFormChoice(array('choices' => array('' => '', 'Mr' => 'Mr', 'Mlle' => 'Mlle', 'Mme' => 'Mme'))),
      'datePermis'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'typePermis'     => new sfWidgetFormChoice(array('choices' => array('' => '', 'A' => 'A', 'B' => 'B'))),
      'departement_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Departement'), 'add_empty' => true)),
      'ville_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Ville'), 'add_empty' => true)),
      'created_at'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'code'           => new sfValidatorPass(array('required' => false)),
      'nom'            => new sfValidatorPass(array('required' => false)),
      'prenom'         => new sfValidatorPass(array('required' => false)),
      'telephone'      => new sfValidatorPass(array('required' => false)),
      'commission'     => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'bloque'         => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'principal'      => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'civilite'       => new sfValidatorChoice(array('required' => false, 'choices' => array('Mr' => 'Mr', 'Mlle' => 'Mlle', 'Mme' => 'Mme'))),
      'datePermis'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'typePermis'     => new sfValidatorChoice(array('required' => false, 'choices' => array('A' => 'A', 'B' => 'B'))),
      'departement_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Departement'), 'column' => 'id')),
      'ville_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Ville'), 'column' => 'id')),
      'created_at'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('conducteur_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Conducteur';
  }

  public function getFields()
  {
    return array(
      'id'             => 'Number',
      'code'           => 'Text',
      'nom'            => 'Text',
      'prenom'         => 'Text',
      'telephone'      => 'Text',
      'commission'     => 'Number',
      'bloque'         => 'Boolean',
      'principal'      => 'Boolean',
      'civilite'       => 'Enum',
      'datePermis'     => 'Date',
      'typePermis'     => 'Enum',
      'departement_id' => 'ForeignKey',
      'ville_id'       => 'ForeignKey',
      'created_at'     => 'Date',
      'updated_at'     => 'Date',
    );
  }
}
